import type {BasicColumn, FormSchema} from '@/components/Table'
import {useRender} from '@/components/Table'
import {DICT_TYPE, getDictOptions} from "@/utils/dict";

export const columns: BasicColumn[] = [
  {
    title: '编号',
    dataIndex: 'id',
    width: 160
  },
  {
    title: '回调名称',
    dataIndex: 'name',
    width: 160
  },
  {
    title: '结果code取值路径',
    dataIndex: 'resCodePath',
    width: 160
  },
  {
    title: '标识成功的code的值eg：200',
    dataIndex: 'successResCode',
    width: 160
  },
  {
    title: '结果message取值路径',
    dataIndex: 'msgPath',
    width: 160
  },
  {
    title: '订单号取值路径-1',
    dataIndex: 'orderIdPath',
    width: 160
  },
  {
    title: '外部订单号取值路径-2',
    dataIndex: 'outerIdPath',
    width: 160
  },
  {
    title: '手机号取值路径',
    dataIndex: 'phonePath',
    width: 160
  },
  {
    title: '所对应业务id',
    dataIndex: 'bizId',
    width: 160
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    }
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '回调名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 8 }
  },
  {
    label: '所对应业务id',
    field: 'bizId',
    component: 'Input',
    colProps: { span: 8 }
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: { span: 8 }
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '回调名称',
    field: 'name',
    required: true,
    component: 'Input'
  },
  {
    label: '结果code取值路径',
    field: 'resCodePath',
    component: 'Input'
  },
  {
    label: '标识成功的code的值eg：200',
    field: 'successResCode',
    component: 'Input'
  },
  {
    label: '结果message取值路径',
    field: 'msgPath',
    component: 'Input'
  },
  {
    label: '订单号取值路径-1',
    field: 'orderIdPath',
    component: 'Input'
  },
  {
    label: '外部订单号取值路径-2',
    field: 'outerIdPath',
    component: 'Input'
  },
  {
    label: '手机号取值路径',
    field: 'phonePath',
    component: 'Input'
  },
  {
    label: '所对应业务id',
    field: 'bizId',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.bizEnum, 'string'),
    },
  },
  {
    label: 'ext',
    field: 'ext',
    component: 'Input'
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
  {
    label: '回调名称',
    field: 'name',
    required: true,
    component: 'Input'
  },
  {
    label: '结果code取值路径',
    field: 'resCodePath',
    component: 'Input'
  },
  {
    label: '标识成功的code的值eg：200',
    field: 'successResCode',
    component: 'Input'
  },
  {
    label: '结果message取值路径',
    field: 'msgPath',
    component: 'Input'
  },
  {
    label: '订单号取值路径-1',
    field: 'orderIdPath',
    component: 'Input'
  },
  {
    label: '外部订单号取值路径-2',
    field: 'outerIdPath',
    component: 'Input'
  },
  {
    label: '手机号取值路径',
    field: 'phonePath',
    component: 'Input'
  },
  {
    label: '所对应业务id',
    field: 'bizId',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.bizEnum, 'string'),
    },
  },
  {
    label: 'ext',
    field: 'ext',
    component: 'Input'
  },
]
